﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
    <script type="text/javascript" src="../../../Content/highlighter/scripts/shCore.js"></script>
    <script type="text/javascript" src="../../../Content/highlighter/scripts/shBrushJScript.js"></script>
    <script type="text/javascript" src="../../../Content/highlighter/scripts/shBrushCSharp.js"></script>
    <script type="text/javascript" src="../../../Content/highlighter/scripts/shBrushXml.js"></script>
    <link type="text/css" rel="stylesheet" href="../../../Content/highlighter/styles/shCore.css" />
    <link type="text/css" rel="stylesheet" href="../../../Content/highlighter/styles/shCoreEclipse.css" />
    <script type="text/javascript">SyntaxHighlighter.all();</script>
</head>
<body>
    <h3>使用parameters获取参数</h3>
    <pre class="brush:csharp;">
    using System;
    using System.Collections.Generic;
    using System.Text;
    using NFinal;

    namespace NFinalWeb3.Controllers
    {
        public class Index1Controller : BaseController
        {
            public ActionResult Index()
            {
                //使用prarameters时，不需要手动转换数据类型。你写什么类型，他就能转成什么类型。
                string UserName= this.parameters["UserName"];
                int UserAge=this.parameters["UserAge"];
                DateTime Birthday=this.parameters["Birthday"];
                return null;
            }
        }
    }
    </pre>
    <h3>如何获取自定义实体类型?</h3>
    <pre class="brush:csharp;">
    public class User
    {
        public string Name{get;set;}
        public string Pwd{get;set;}
    }
    </pre>
    <h3>1.使用GetJson获取参数</h3>
    <pre class="brush:csharp;">
    using System;
    using System.Collections.Generic;
    using System.Text;
    using NFinal;

    namespace NFinalWeb3.Controllers
    {
        public class Index1Controller : BaseController
        {
            public ActionResult Index()
            {
                //使用prarameters时，不需要手动转换数据类型。你写什么类型，他就能转成什么类型。
                var user=this.GetJson&lt;User>();
                return null;
            }
        }
    }
    </pre>
    <h3>2.使用GetModel获取参数</h3>
    <pre class="brush:csharp;">
    using System;
    using System.Collections.Generic;
    using System.Text;
    using NFinal;

    namespace NFinalWeb3.Controllers
    {
        public class Index1Controller : BaseController
        {
            public ActionResult Index()
            {
                //使用prarameters时，不需要手动转换数据类型。你写什么类型，他就能转成什么类型。
                var user=this.GetModel&lt;User>();
                return null;
            }
        }
    }
    </pre>
    <h3>3.使用函数参数获取参数</h3>
    <pre class="brush:csharp;">
    using System;
    using System.Collections.Generic;
    using System.Text;
    using NFinal;

    namespace NFinalWeb3.Controllers
    {
        public class Index1Controller : BaseController
        {
            public ActionResult Index(User user)
            {
                return Json();
            }
        }
    }
    </pre>
</body>
</html>